//Khai bao thu vien
#include<conio.h>
#include<stdio.h>
//Ham kiem tra so nguyen to
int nguyento(int n)
{
	//Khai bao bien
	int i,kq;
	kq = 1; 			//Gia su n la so nguyen to
 	if(n<2)
 	{
	 	kq=0;			//Neu n<2 thi n khong la so nguyen to
 	}
 	for(i=2;i<=n/2;i++)
 	{
		if(n % i == 0)	//Neu k chia het cho i
	 	{
 	 		kq = 0;
		 	 break;		//Mat lap;
	  	}			
 	}
 	return kq;
}
//Ham in nguyen to
void innguyento(int n)
{
		//In ra so nguyen to
		for(int i=1;i<=n;i++)
		{
			if (nguyento(i))
				printf("%7d",i);
		}
}

void main()
{
	//Khai bao bien
	int n;
	//Xoa man hinh
	clrscr();
	printf("\n\tCHUONG TRINH IN N SO NGUYEN TO DAU TIEN");
	printf("\n\tNhap n:");
	scanf("%d",&n);
	innguyento(n);
   	getch();
}
